package account.view;

import java.util.ArrayList;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="viewManager")
@SessionScoped
public class ViewManager {
	
	public class MenuItem {
		
		private String name;
		private boolean check;
		private String naviLabel;
		
		public MenuItem() {}
		
		public MenuItem(String name, String naviLabel) {
			super();
			this.name = name;
			this.check = false;
			this.naviLabel = naviLabel;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}

		public boolean isCheck() {
			return check;
		}
		public void setCheck(boolean check) {
			this.check = check;
		}
		
		public String action() {
			
			return null;
		}

		public String getNaviLabel() {
			return naviLabel;
		}
		
		
	}

	private ViewHelper helper;
	private ArrayList< MenuItem > menu = new ArrayList< MenuItem >();
	{
		menu.add( new MenuItem( "DRL",  ViewHelper.DRL ) ); 
		menu.add( new MenuItem( "Konta",  ViewHelper.DEFAULT) ); 

	}
	
	@PostConstruct
	public void create() {
		helper = new ViewHelper();
	}

	public String getLeftView() {
		return helper.getViewLayold()[ViewHelper.VIEW_LEFT];
	}	
	
	public String getRightView() {
		return helper.getViewLayold()[ViewHelper.VIEW_RIGHT];
	}	
	
	public String getContentView() {
		return helper.getViewLayold()[ViewHelper.VIEW_CONTENT];
	}

	public String getMenutView() {
		return helper.getViewLayold()[ViewHelper.VIEW_MENU];
	}
	
	public ArrayList<MenuItem> getMenu() {
		return menu;
	}

	public void setMenu(ArrayList<MenuItem> menu) {
		this.menu = menu;
	}
	
	public void setMenuPosition( String item ) {
		for( MenuItem menuItem : menu ) {
			if( menuItem.name.equals( item )) {
				menuItem.setCheck(true);
			} else {
				menuItem.setCheck(false);
			}
			
		}
		
		helper.setCurrMenuPos( item );
	}
	
	
	
}
